package Api;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class Student implements Comparable<Student>{
    private String name;
    private int score;
    public Student(String name,int score){
        this.name = name;
        this.score=score;
    }
    public int compareTo(Student o){
        return this.score-o.score;
    }
    public String toString() {
        return "学生:"+name+"成绩:"+score;
    }
}
public class CollectionsSortDemo02 {
    public static void main(String[] args) {
        List<Student>list=new ArrayList<>();
        list.add(new Student("Jerry",90));
        list.add(new Student("Tom",100));
        list.add(new Student("Jake",80));
        Collections.sort(list);
        System.out.println(list);
    }
}
